package iagovsothello.logger;

import iagovsothello.ai.Agent;

import java.util.Iterator;
import java.util.LinkedList;


public class Log implements java.io.Serializable {

	private static final long serialVersionUID = -9127563240879777798L;

	private Agent player1;
	private Agent player2;
	
	private LinkedList<Entry> entries;
	
	public Log(Agent player1, Agent player2)
	{
		this.player1 = player1;
		this.player1.setLog(this);
		this.player2 = player2;
		this.player2.setLog(this);
		entries = new LinkedList<Entry>();
	}
	
	public Agent getPlayer1() 
	{
		return player1;
	}

	public Agent getPlayer2()
	{
		return player2;
	}

	public void add(Entry e)
	{
		entries.add(e);
	}
	
	public Iterator<Entry> iterator()
	{
		return entries.iterator();
	}
	
	public int size()
	{
		return entries.size();
	}
	
	public String toString()
	{
		String s = "Player1: "+player1+"\nPlayer2: "+player2+"\n--------------------------------\n";
		int i = 1;
		for (Entry e : entries)
		{
			s = s + "Mossa "+i+", giocatore "+e.currentPlayer+"\n\n";
			i++;
		}
		return s;
	}
}
